package ch2;

import java.util.Scanner;

/**
 * Created by 竹韵澜 on 2017/7/18.
 * PP2.8
 */
public class PiggyBank {
    public static void main(String[] args) {
        int yuan1,jiao1,jiao2,jiao5,fen1,fen2,fen5;
        int yuan,jiao,fen;
        int extra_jiao,extra_yuan;

        Scanner scan1 = new Scanner (System.in);
        Scanner scan2 = new Scanner (System.in);
        Scanner scan3 = new Scanner (System.in);
        Scanner scan4 = new Scanner (System.in);
        Scanner scan5 = new Scanner (System.in);
        Scanner scan6 = new Scanner (System.in);
        Scanner scan7 = new Scanner (System.in);

        System.out.print("Enter the number of 1yuan coins:");
        yuan1 = scan1.nextInt();
        System.out.print("Enter the number of 1jiao coins:");
        jiao1 = scan2.nextInt();
        System.out.print("Enter the number of 2jiao coins:");
        jiao2 = scan3.nextInt();
        System.out.print("Enter the number of 5jiao coins:");
        jiao5 = scan4.nextInt();
        System.out.print("Enter the number of 1fen coins:");
        fen1 = scan5.nextInt();
        System.out.print("Enter the number of 2fen coins:");
        fen2 = scan6.nextInt();
        System.out.print("Enter the number of 5fen coins:");
        fen5 = scan7.nextInt();

        fen = fen1 + fen2 * 2 + fen5 * 5;

        if (fen > 10 ) {
            extra_jiao = (fen - fen % 10) / 10;
            fen = fen % 10;
        }
        else
            extra_jiao = 0;

        jiao = jiao1 + jiao2 * 2 + jiao5 * 5 + extra_jiao;

        if (jiao > 10 ) {
            extra_yuan = (jiao - jiao % 10) / 10;
            jiao = jiao % 10;
        }
        else
            extra_yuan = 0;

        yuan = yuan1 + extra_yuan;


        System.out.print("Totol coins in this piggy bank costs:"
        + yuan + " yuan " + jiao + " jiao " + fen + " fen ");
    }

}
